home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 001-025 / disk_023 / ver30 / gnucmds.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  2KB  |  111 lines

  1. /*
  2.  * Name:    MicroEMACS
  3.  *        GNU compatible commands
  4.  * Version:    29
  5.  * Last edit:    19-Apr-86
  6.  * By:        {sun, amdahl, mtxinu}!rtech!daveb
  7.  *
  8.  * This file contains new commands written for GNU emacs compatibility.
  9.  *
  10.  *    suspend(),        replacing jeffexit().
  11.  *    savebuffs(),        new.
  12.  *    savequit(),        new.
  13.  *    notmodified(),        new.
  14.  *    findalternate(),    new.
  15.  *    scrollother(),        new.
  16.  */
  17. #include    "def.h"
  18.  
  19. /*
  20.  * GNU style suspend.  Asks to save all dirty buffs, then starts a CLI.
  21.  * Bound to "C-Z" and "X-C-Z"
  22.  *
  23.  * Supercedes "jeffexit"    X-C-Z too.
  24.  */
  25. suspend(f, n, k)
  26. {
  27.     if(ABORT != savebuffs(0, 0, KRANDOM))
  28.         return (spawncli(f, n, KRANDOM));
  29.     else
  30.         return (ABORT);
  31. }
  32.  
  33. /*
  34.  * GNU compatible buffer save routine.
  35.  * Scan all buffers and ask for disposition.
  36.  * Does not affect display.    X-S
  37.  * (daveb)
  38.  */
  39. savebuffs(f, n, k)
  40. {
  41.     char        buf[ 80 ];
  42.     register int    s;
  43.     register    BUFFER *bp;
  44.     BUFFER        *oldbp = curbp;
  45.     int        considered = FALSE;
  46.     int        row = ttrow;
  47.     int        col = ttcol;
  48.  
  49.     for( bp = bheadp; bp != NULL; bp = bp->b_bufp )
  50.         if (bp->b_bname[0]!=' ' && bp->b_fname[0]!='\0' 
  51.             && (bp->b_flag&BFCHG) != 0) {
  52.             considered = TRUE;
  53.             strcpy( buf, "Save file ");
  54.             strcat( buf, bp->b_fname );
  55.             s = eyesno( buf, bp->b_fname);
  56.             if (s == ABORT)
  57.                 return (ABORT);
  58.             if (s == TRUE) {
  59.                 curbp = bp;
  60.                 filesave(f, n, KRANDOM);
  61.                 ttmove( row, col );
  62.                 ttflush();
  63.             }
  64.         }
  65.     if(!considered)
  66.         eprintf("(No files need saving)");
  67.     curbp = oldbp;
  68.     ttmove( row, col );
  69.     ttflush();
  70.     return(TRUE);
  71. }
  72.  
  73. /*
  74.  * GNU style exit:  query on every dirty buffer, then exit.  X-C-C
  75.  */
  76. savequit(f, n, k)
  77. {
  78.     if(ABORT != savebuffs(0, 0, KRANDOM))
  79.         quit(f, n, k);
  80.     return( ABORT );
  81. }
  82.  
  83. /*
  84.  * Turn off the dirty bit on this buffer.  M-~
  85.  */
  86. notmodified(f, n, k)
  87. {
  88.     register WINDOW *wp;
  89.     
  90.     curbp->b_flag &= ~BFCHG;
  91.     wp = wheadp;                /* Update mode lines.    */
  92.     while (wp != NULL) {
  93.         if (wp->w_bufp == curbp)
  94.             wp->w_flag |= WFMODE;
  95.         wp = wp->w_wndp;
  96.     }
  97.     eprintf("Modification-flag cleared");
  98.     return (TRUE);
  99. }
  100.  
  101. /*
  102.  * Scroll the other window.  On C-M-V.  Works OK (daveb).
  103.  */
  104. scrollother(f, n, k)
  105. {
  106.     nextwind(0, 0, KRANDOM);
  107.     forwpage(f, n, k);
  108.     prevwind(0, 0, KRANDOM);
  109. }
  110.  
  111.